%**************************************************************
%
% Calculates the theoretical value for the velocity (m/s) 
% Autor: Carlos Amaral (ceamaral@hotmail.com)/Rafael Fabricio
% date: 07/10/2010
%**************************************************************

function [velocity_theory] =  calcule_velocity_theory(JL_aux,JG_aux,tube_diameter)

J_aux = JL_aux + JG_aux;
pL=999;
pG=1.17;
g=9.80665;
mL=0.001;
Tau=0.07;

Rem=pL*J_aux*tube_diameter/mL;
Fr=J_aux/sqrt(g*tube_diameter);
Eo=tube_diameter^2*g*(pL-pG)/Tau;

if Rem<1000
    Co=2;
    Cinf=(0.542-1.76/(Eo^0.56));
else
    if Fr<3.5
        Co=1;
        Cinf=(0.542-1.76/(Eo^0.56));
    else
        Co=1.2;
        Cinf=0;
    end
end
velocity_theory = Co*J_aux+Cinf*sqrt(g*tube_diameter);

return